﻿<Framework:BasePage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:Framework="clr-namespace:JustinAngel.UnitedNationsNews.Framework" xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls" 
    xmlns:controlsPrimitives="clr-namespace:Microsoft.Phone.Controls.Primitives;assembly=Microsoft.Phone.Controls" xmlns:Controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit" xmlns:Custom="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:GalaSoft_MvvmLight_Command="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WP7" xmlns:System="clr-namespace:System;assembly=mscorlib" x:Class="JustinAngel.UnitedNationsNews.Pages.Photos.PhotosPage"
    SupportedOrientations="PortraitOrLandscape" Orientation="Landscape"
    mc:Ignorable="d" d:DesignHeight="480" d:DesignWidth="800"
	
	 shell:SystemTray.IsVisible="False" d:DataContext="{d:DesignData /SampleData/PhotosViewModelSampleData.xaml}" Foreground="Black">
	<Framework:BasePage.Resources>
		<DataTemplate x:Key="PhotoHeaderDataTemplate">
			<TextBlock Text="should not be visible"/>
		</DataTemplate>
		<DataTemplate x:Key="PhotoItemDataTemplate">
			<Grid>
				<Image Source="{Binding ImageUri}" Stretch="Uniform"/>
			</Grid>
		</DataTemplate>
		<Style x:Key="PhotosPivotControl" TargetType="controls:Pivot">
			<Setter Property="Margin" Value="0"/>
			<Setter Property="Padding" Value="0"/>
			<Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
			<Setter Property="Background" Value="Transparent"/>
			<Setter Property="ItemsPanel">
				<Setter.Value>
					<ItemsPanelTemplate>
						<Grid/>
					</ItemsPanelTemplate>
				</Setter.Value>
			</Setter>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="controls:Pivot">
						<Grid HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}">
							<Grid.RowDefinitions>
								<RowDefinition Height="*"/>
							</Grid.RowDefinitions>
							<ItemsPresenter x:Name="PivotItemPresenter" Margin="{TemplateBinding Padding}" />
						</Grid>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
		<Style x:Key="PhotoItemContainerStyle" TargetType="controls:PivotItem">
			<Setter Property="Margin" Value="0"/>
		</Style>
	</Framework:BasePage.Resources>
 
	<Framework:BasePage.FontFamily>
		<StaticResource ResourceKey="PhoneFontFamilyNormal"/>
	</Framework:BasePage.FontFamily>
	<Framework:BasePage.FontSize>
		<StaticResource ResourceKey="PhoneFontSizeNormal"/>
	</Framework:BasePage.FontSize>
	<Framework:BasePage.ViewModel>
		<Binding Path="PhotosViewModel" Source="{StaticResource ViewModelLocator}"/>
	</Framework:BasePage.ViewModel>
    
    <Framework:BasePage.ApplicationBar>
        <shell:ApplicationBar BackgroundColor="#FF5B92E5" ForegroundColor="White">
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="share via email" Click="AppBarShareViaEmail" />
                <shell:ApplicationBarMenuItem Text="share on facebook" Click="AppBarShareOnFacebook" />
                <shell:ApplicationBarMenuItem Text="share on twitter" Click="AppBarShareOnTwitter" />
            </shell:ApplicationBar.MenuItems>
            <shell:ApplicationBarIconButton IconUri="/Pages/Photos/appbar.back.rest.png" Text="Previous" Click="AppBarPreviousClick" />
            <shell:ApplicationBarIconButton IconUri="/Pages/Photos/appbar.save.rest.png" Text="Save" Click="AppBarSaveClick" />
            <shell:ApplicationBarIconButton IconUri="/Pages/Photos/appbar.next.rest.png" Text="Next" Click="AppBarNextClick" />
        </shell:ApplicationBar>
    </Framework:BasePage.ApplicationBar>

    <Grid x:Name="LayoutRoot">
    	<Grid.Background>
    		<ImageBrush Stretch="UniformToFill" ImageSource="/UNNewsSinglePageBackground.jpg"/>
    	</Grid.Background>
    	<Grid.RowDefinitions>
    		<RowDefinition Height="*" />
			<RowDefinition Height="Auto" />  	
		</Grid.RowDefinitions>
    	<VisualStateManager.VisualStateGroups>
    		<VisualStateGroup x:Name="DetailsStates">
    			<VisualStateGroup.Transitions>
    				<VisualTransition From="IsDetailsVisible" GeneratedDuration="0:0:0.3" To="NotIsDetailsVisible"/>
    				<VisualTransition From="NotIsDetailsVisible" GeneratedDuration="0:0:0.3" To="IsDetailsVisible"/>
    			</VisualStateGroup.Transitions>
    			<VisualState x:Name="IsDetailsVisible">
    				<Storyboard>
    					<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="border">
    						<DiscreteObjectKeyFrame KeyTime="0">
    							<DiscreteObjectKeyFrame.Value>
    								<Visibility>Visible</Visibility>
    							</DiscreteObjectKeyFrame.Value>
    						</DiscreteObjectKeyFrame>
    					</ObjectAnimationUsingKeyFrames>
    					<DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="border" d:IsOptimized="True"/>
    				</Storyboard>
    			</VisualState>
    			<VisualState x:Name="NotIsDetailsVisible">
    				<Storyboard>
    					<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="border" d:IsOptimized="True"/>
    					<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="border">
    						<DiscreteObjectKeyFrame KeyTime="0">
    							<DiscreteObjectKeyFrame.Value>
    								<Visibility>Collapsed</Visibility>
    							</DiscreteObjectKeyFrame.Value>
    						</DiscreteObjectKeyFrame>
    					</ObjectAnimationUsingKeyFrames>
    				</Storyboard>
    			</VisualState>
    		</VisualStateGroup>
    	</VisualStateManager.VisualStateGroups>
        <Controls:GestureService.GestureListener>
            <Controls:GestureListener Tap="GestureListener_Tap" />
        </Controls:GestureService.GestureListener>
     
    	<controls:Pivot x:Name="photosPivot" HeaderTemplate="{StaticResource PhotoHeaderDataTemplate}" ItemsSource="{Binding Photos}" Title="Should not be visible" ItemTemplate="{StaticResource PhotoItemDataTemplate}" Style="{StaticResource PhotosPivotControl}" ItemContainerStyle="{StaticResource PhotoItemContainerStyle}" SelectedIndex="{Binding SelectedPhotoIndex, Mode=TwoWay}"/>
    	<Border x:Name="border" VerticalAlignment="Bottom" Background="#99FFFFFF"  Grid.Row="1">
    		<StackPanel x:Name="stackPanel" Margin="24,0,12,12">
    			<TextBlock Margin="0" Style="{StaticResource PhoneTextLargeStyle}" TextWrapping="Wrap" Text="{Binding CurrentTitle}" d:LayoutOverrides="Width, Height" Foreground="Black"/>
    			<TextBlock HorizontalAlignment="Left" Margin="0" Style="{StaticResource PhoneTextNormalStyle}" TextWrapping="Wrap" Text="{Binding CurrentDescription}" VerticalAlignment="Top" Foreground="Black"/>
    		</StackPanel>
    	</Border>
    </Grid>

</Framework:BasePage>
